package guda.shop.core.manager.impl;

import guda.shop.common.hibernate3.Updater;
import guda.shop.common.page.Pagination;
import guda.shop.core.dao.LogDao;
import guda.shop.core.entity.Log;
import guda.shop.core.manager.LogMng;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
@Transactional
public class LogMngImpl
        implements LogMng {
    private LogDao logDao;

    @Transactional(readOnly = true)
    public Pagination getPage(int paramInt1, int paramInt2) {
        Pagination localPagination = this.logDao.getPage(paramInt1, paramInt2);
        return localPagination;
    }

    @Transactional(readOnly = true)
    public Log findById(Long paramLong) {
        Log localLog = this.logDao.findById(paramLong);
        return localLog;
    }

    public Log save(Log paramLog) {
        this.logDao.save(paramLog);
        return paramLog;
    }

    public void save(String paramString1, String paramString2) {
        Date localDate = new Date();
        Log localLog = new Log();
        localLog.setContent(paramString2);
        localLog.setTitle(paramString1);
        localLog.setCategory(Integer.valueOf(1));
        localLog.setTime(localDate);
        this.logDao.save(localLog);
    }

    public Log update(Log paramLog) {
        Updater localUpdater = new Updater(paramLog);
        Log localLog = this.logDao.updateByUpdater(localUpdater);
        return localLog;
    }

    public Log deleteById(Long paramLong) {
        Log localLog = this.logDao.deleteById(paramLong);
        return localLog;
    }

    public Log[] deleteByIds(Long[] paramArrayOfLong) {
        Log[] arrayOfLog = new Log[paramArrayOfLong.length];
        int i = 0;
        int j = paramArrayOfLong.length;
        while (i < j) {
            arrayOfLog[i] = deleteById(paramArrayOfLong[i]);
            i++;
        }
        return arrayOfLog;
    }

    @Autowired
    public void setDao(LogDao paramLogDao) {
        this.logDao = paramLogDao;
    }
}

